package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.SpBean;
import com.lwj.liwanjia.impl.SpView;
import com.lwj.liwanjia.model.SpModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/31.
 */

public class SpPresenter {
    private SpModel spModel;
    private SpView spView;

    public SpPresenter(SpView spView) {
        this.spView = spView;
        spModel = new SpModel();
    }

    public void getSpData(String id) {
        if (spView != null) {
            spModel.getSpData(id, new Subscriber<SpBean>() {
                @Override
                public void onCompleted() {
                    spView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    spView.showError((Exception) e);
                    spView.hideProgress();
                }

                @Override
                public void onNext(SpBean spBean) {
                    spView.getSpData(spBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    spView.showProgress();
                }
            });
        }
    }
}
